<?php

namespace app\modules\api\controllers;

use app\components\API;
use app\models\Jobs;
use phpDocumentor\Reflection\Types\Null_;
use \yii\web\Controller;
use Yii;

class AppController extends Controller
{

    public $layout = 'main_m';
    public $enableCsrfValidation = false;
    private $apilist = [
        'getNowUserInfo' => [
            'call' => 'app\components\Api\User@info',
            'authority' => 'all'
        ],
        'getjiguang'=>[
            'call' => 'app\components\Api\JMessageApi@getjiguang',
            'authority' => 'all'///user
        ],
        'setUserTypeIntroducer'=>[
            'call' => 'app\components\Api\User@setUserTypeIntroducer',
            'authority' => 'user'///user
        ],
        'getusers_info_gs'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'getusers_info_gc'=>[
            'call' => 'app\components\Api\User@getusers_info_gc',
            'authority' => 'user'///user
        ],
        'getusers_info_gr'=>[
            'call' => 'app\components\Api\User@getusers_info_gr',
            'authority' => 'user'///user
        ],






        'getusers_baseinfo_gs'=>[
            'call' => 'app\components\Api\User@getusers_baseinfo_gs',
            'authority' => 'user'///user
        ],
        'getusers_baseinfo_gc'=>[
            'call' => 'app\components\Api\User@getusers_baseinfo_gc',
            'authority' => 'user'///user
        ],
        'getusers_baseinfo_gr'=>[
            'call' => 'app\components\Api\User@getusers_baseinfo_gr',
            'authority' => 'user'///user
        ],






        'setusers_baseinfo_gs'=>[
            'call' => 'app\components\Api\User@setusers_baseinfo_gs',
            'authority' => 'user'///user
        ],
        'setusers_baseinfo_gc'=>[
            'call' => 'app\components\Api\User@setusers_baseinfo_gc',
            'authority' => 'user'///user
        ],
        'setusers_baseinfo_gr'=>[
            'call' => 'app\components\Api\User@setusers_baseinfo_gr',
            'authority' => 'user'///user
        ],











        'getusers_zhengjianshangchuan_gs'=>[
            'call' => 'app\components\Api\User@getusers_zhengjianshangchuan_gs',
            'authority' => 'user'///user
        ],

        'getusers_zhengjianshangchuan_gc'=>[
            'call' => 'app\components\Api\User@getusers_zhengjianshangchuan_gc',
            'authority' => 'user'///user
        ],

        'getusers_zhengjianshangchuan_gr'=>[
            'call' => 'app\components\Api\User@getusers_zhengjianshangchuan_gr',
            'authority' => 'user'///user
        ],





        'setusers_zhengjianshangchuan_gs'=>[
            'call' => 'app\components\Api\User@setusers_zhengjianshangchuan_gs',
            'authority' => 'user'///user
        ],
        'setusers_zhengjianshangchuan_gc'=>[
            'call' => 'app\components\Api\User@setusers_zhengjianshangchuan_gc',
            'authority' => 'user'///user
        ],
        'setusers_zhengjianshangchuan_gr'=>[
            'call' => 'app\components\Api\User@setusers_zhengjianshangchuan_gr',
            'authority' => 'user'///user
        ],
        'getusers_basechanpin_gs'=>[
            'call' => 'app\components\Api\User@getusers_basechanpin_gs',
            'authority' => 'user'///user
        ],
        'getusers_basechanpin_gc'=>[
            'call' => 'app\components\Api\User@getusers_basechanpin_gc',
            'authority' => 'user'///user
        ],





        'setusers_basechanpin_gs'=>[
            'call' => 'app\components\Api\User@setusers_basechanpin_gs',
            'authority' => 'user'///user
        ],

        'setusers_basechanpin_gc'=>[
            'call' => 'app\components\Api\User@setusers_basechanpin_gc',
            'authority' => 'user'///user
        ],

        'getgongchangshebei_gc'=>[
            'call' => 'app\components\Api\User@getgongchangshebei_gc',
            'authority' => 'user'///user
        ],

        'setgongchangshebei_gc'=>[
            'call' => 'app\components\Api\User@setgongchangshebei_gc',
            'authority' => 'user'///user
        ],




        'getusers_basechanpinfengge_gs'=>[
            'call' => 'app\components\Api\User@getusers_basechanpinfengge_gs',
            'authority' => 'user'///user
        ],
        'setusers_basechanpinfengge_gs'=>[
            'call' => 'app\components\Api\User@setusers_basechanpinfengge_gs',
            'authority' => 'user'///user
        ],
        'getusers_basezhiliangbiaozhun_gs'=>[
            'call' => 'app\components\Api\User@getusers_basezhiliangbiaozhun_gs',
            'authority' => 'user'///user
        ],
        'setusers_basezhiliangbiaozhun_gs'=>[
            'call' => 'app\components\Api\User@setusers_basezhiliangbiaozhun_gs',
            'authority' => 'user'///user
        ],
        'getusers_gongsihuanjing_gs'=>[
            'call' => 'app\components\Api\User@getusers_gongsihuanjing_gs',
            'authority' => 'user'///user
        ],
        'setusers_gongsihuanjing_gs'=>[
            'call' => 'app\components\Api\User@setusers_gongsihuanjing_gs',
            'authority' => 'user'///user
        ],



        'getusers_chanliangchanneng_gc'=>[
            'call' => 'app\components\Api\User@getusers_chanliangchanneng_gc',
            'authority' => 'user'///user
        ],
        'setusers_chanliangchanneng_gc'=>[
            'call' => 'app\components\Api\User@setusers_chanliangchanneng_gc',
            'authority' => 'user'///user
        ],
        'getusers_zhiliangyaoqiu_gc'=>[
            'call' => 'app\components\Api\User@getusers_zhiliangyaoqiu_gc',
            'authority' => 'user'///user
        ],
        'setusers_zhiliangyaoqiu_gc'=>[
            'call' => 'app\components\Api\User@setusers_zhiliangyaoqiu_gc',
            'authority' => 'user'///user
        ],
        'getusers_gongchanghuanjing_gc'=>[
            'call' => 'app\components\Api\User@getusers_gongchanghuanjing_gc',
            'authority' => 'user'///user
        ],



        'setusers_gongchanghuanjing_gc'=>[
            'call' => 'app\components\Api\User@setusers_gongchanghuanjing_gc',
            'authority' => 'user'///user
        ],
        'getuser_jiaoyubeijing_gr'=>[
            'call' => 'app\components\Api\User@getuser_jiaoyubeijing_gr',
            'authority' => 'user'///user
        ],
        'getUserJiaoyubeijingGr'=>[
            'call' => 'app\components\Api\User@getUserJiaoyubeijingGr',
            'authority' => 'user'///user
        ],
        'setuser_jiaoyubeijing_gr'=>[
            'call' => 'app\components\Api\User@setuser_jiaoyubeijing_gr',
            'authority' => 'user'///user
        ],
        'getuser_gongzuojingli_gr'=>[
            'call' => 'app\components\Api\User@getuser_gongzuojingli_gr',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



        'ooooooooo'=>[
            'call' => 'app\components\Api\User@getusers_info_gs',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],
        'ooooooooo'=>[
            'call' => 'app\components\Api\User@ooooooooo',
            'authority' => 'user'///user
        ],



    ];

    public function actionCall($id)
    {
        // exit($id);
        $one = $this->getApi($id);
        if (!$one) {
            return API::echo_json(1, $id . '接口不存在');
        }
        $call = $one['call'];
        $authority = $one['authority'];

        if ($authority == 'user') {
            if (Yii::$app->user->isGuest) {
                return API::echo_json(-1001);
            }
        }
        $apilist = explode('@', $call);
        $className = $apilist[0];
        $classCall = isset($apilist[1]) ? $apilist[1] : null;
        if (!class_exists($className)) {
            API::echo_json(1, '接口调用失败，接口类不存在' . $className);
        }
        try {
            $new = new $className();
            return $new->$classCall($_POST,[]);
        } catch (Exception $e) {
            return API::echo_json(1, '接口调用失败' . $e->getMessage());
        }
        ///exit('ccccccccccc');
    }

    private function getApi($id)
    {
        return $this->apilist[$id] ?? null;
    }



    public $title = '测试系统';
    public $description = '测试系统';

}
